using System;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace Net35.Xrm.Sdk
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
	internal sealed class KnownAssemblyAttribute : Attribute, System.ServiceModel.Description.IContractBehavior
	{
		private KnownTypesResolver resolver;
		public KnownAssemblyAttribute()
		{
			this.resolver = new KnownTypesResolver();
		}
		public void AddBindingParameters(System.ServiceModel.Description.ContractDescription contractDescription, System.ServiceModel.Description.ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
		{
		}
		public void ApplyClientBehavior(System.ServiceModel.Description.ContractDescription contractDescription, System.ServiceModel.Description.ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime)
		{
			this.CreateMyDataContractSerializerOperationBehaviors(contractDescription);
		}
		public void ApplyDispatchBehavior(System.ServiceModel.Description.ContractDescription contractDescription, System.ServiceModel.Description.ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.DispatchRuntime dispatchRuntime)
		{
			this.CreateMyDataContractSerializerOperationBehaviors(contractDescription);
		}
		public void Validate(System.ServiceModel.Description.ContractDescription contractDescription, System.ServiceModel.Description.ServiceEndpoint endpoint)
		{
		}
		private void CreateMyDataContractSerializerOperationBehaviors(System.ServiceModel.Description.ContractDescription contractDescription)
		{
			foreach (System.ServiceModel.Description.OperationDescription current in contractDescription.Operations)
			{
				this.CreateMyDataContractSerializerOperationBehavior(current);
			}
		}
		private void CreateMyDataContractSerializerOperationBehavior(System.ServiceModel.Description.OperationDescription operation)
		{
			System.ServiceModel.Description.DataContractSerializerOperationBehavior dataContractSerializerOperationBehavior = operation.Behaviors.Find<System.ServiceModel.Description.DataContractSerializerOperationBehavior>();
			if (dataContractSerializerOperationBehavior != null)
			{
				//dataContractSerializerOperationBehavior.DataContractResolver = this.resolver;
			}
		}
	}
}
